#ifndef TWI_H_
#define TWI_H_

#include <avr/io.h>
#include <inttypes.h>
#include <compat/twi.h>

#define SCL_CLOCK 100000L


/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */
#define I2C_READ    1

/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */
#define I2C_WRITE   0

 
#define i2c_read(ack)  (ack) ? i2c_readAck() : i2c_readNak(); 

// define the Clock pin information here
#define TWI_PORTC 		PORTC
#define TWI_DDRC 		DDRC
#define TWI_PINC 		PINC
#define TWI_SCK 		0

// define the Data pin information here
#define TWI_PORTD 		PORTC
#define TWI_DDRD 		DDRC
#define TWI_PIND 		PINC
#define TWI_SDA 		1

void 	TWI_init		(void);  	// initializes the I2C hardware
uint8_t TWI_start(uint8_t address);	// generates the start condition
void 	TWI_stop		(void);		// generates the stop condition

uint8_t TWI_readAck(void);			//read the Acknowledge
uint8_t TWI_readNak(void);			//read the Nak
#endif /* TWI_H_ */
